package com.lihao.sam.controller;

import com.lihao.sam.entity.Company;
import com.lihao.sam.entity.CompanyEmp;
import com.lihao.sam.service.intf.CompanyEmpService;
import com.lihao.sam.service.intf.CompanyService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author LiHao
 * @Description CompanyEmpController
 * @Date 13:10 2022/11/22
 */
@RestController
@RequestMapping("/api/companyemp/")
public class CompanyEmpController {
    @Resource
    private CompanyEmpService service;

    @PostMapping("add.do")
    public R add(CompanyEmp companyEmp) {
        return service.addTX(companyEmp);
    }

    @PostMapping("update.do")
    public R update(CompanyEmp companyEmp) {
        return service.updateTX(companyEmp);
    }

    @PostMapping("delete.do")
    public R delete(int id, HttpSession session) {
        return service.deleteTX(id);
    }

    @GetMapping("page.do")
    public PageVo page(int page, int limit, String workId, String empName, String houseId) {
        return service.queryPage(page, limit, workId, empName, houseId);
    }

    @PostMapping("upload.do")
    public R upload(MultipartFile file) throws IOException {
        return service.uploadExcel(file);
    }
    @PostMapping("deletebatch.do")
    public R deleteBatch(int[] ids) {
        return service.deleteBatch(ids);
    }

    @GetMapping("companyempcount.do")
    public R companyEmpCount(){
        return service.queryCompanyEmpCount();
    }
}
